
class Animal {
    public int age;
    public String name;

    //默认
/*
    public Animal() {

    }
*/

    public Animal(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public void eat() {
        System.out.println(name + "吃饭");
    }
}

class Cat extends Animal{
    //不加特有属性
    public String name;
    public Cat() {
        super(10, "bitch");
    }
    public void CatchMouse() {
        //访问父类同名成员变量
        System.out.println(super.name + "抓老鼠");
        //内部类中访问外部类同名成员变量
        //System.out.println(Animal.this.name);
        //调用父类的普通成员方法 不能用super、this调用静态成员方法和成员变量
        super.eat();
    }
    //public static void staticFunc() {
    //    System.out.println(super.name);
    //} erro
}
class Dog extends Animal {
    public boolean silly;

    //默认
    /*public Dog() {
        super();
    }*/
    public Dog(int age, String name, boolean silly) {
        //先帮助父类初始化
        super(age, name);
        this.silly = silly;
    }

    public void houseGuard() {
        System.out.println(name + "看家");
    }
}
public class Test {
    public static void main2(String[] args) {
        Dog dog = new Dog(10, "whea", true);

    }
    public static void main(String[] args) {
        Cat cat = new Cat();
        cat.name = "bitch";
        cat.CatchMouse();
    }
}
